<template>
  <div class="myTr">
    <table>
      <tbody>
        <tr v-for="(item, index) in goodsArr" :key="index">
          <td><input @change="changeFn(index)" :count="item.count" type="number" :value="item.count" :theIndex="index"/></td>
          <td>
            {{ item.goodsName }}
          </td>
          <td v-if="!item.count">
            <i>卖完了！！！</i>
          </td>
        </tr>
      </tbody>
    </table>
  </div>
</template>

<script>
export default {
  name: "DoghtmlTr",
  props: ["goodsArr"],
  data() {
    return {
        count:0,
    };
  },
  computed:{
        sum(){
            let sumM=0
         return this.goodsArr.forEach(ele=>sumM+=ele.count);
        }
  },
  mounted() {},

  methods: {
      changeFn(index){
        this.count=this.count+1
        this.$emit('changeTo',index,this.count)
    }
  },
};
</script>

<style lang="scss" scoped>
</style>